home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / LANG / C / LIB / UNIXLIB37B / !UnixLib37 / src / clib / sys / h / resource < prev    next >
C/C++ Source or Header  |  1996-11-09  |  5KB  |  167 lines

  1. /****************************************************************************
  2.  *
  3.  * $Source: /unixb/home/unixlib/source/unixlib37/src/clib/sys/h/RCS/resource,v $
  4.  * $Date: 1996/10/30 21:58:59 $
  5.  * $Revision: 1.3 $
  6.  * $State: Rel $
  7.  * $Author: unixlib $
  8.  *
  9.  * $Log: resource,v $
  10.  * Revision 1.3  1996/10/30 21:58:59  unixlib
  11.  * Massive changes made by Nick Burret and Peter Burwood.
  12.  *
  13.  * Revision 1.2  1996/05/06 09:01:33  unixlib
  14.  * Updates to sources made by Nick Burrett, Peter Burwood and Simon Callan.
  15.  * Saved for 3.7a release.
  16.  *
  17.  * Revision 1.1  1996/04/19 21:23:56  simon
  18.  * Initial revision
  19.  *
  20.  ***************************************************************************/
  21.  
  22. #ifndef    __SYS_RESOURCE_H
  23. #define    __SYS_RESOURCE_H 1
  24.  
  25. /* Needed for the definition of struct timeval.  */
  26. #ifndef __SYS_TIME_H
  27. #include <sys/time.h>
  28. #endif
  29.  
  30. #ifdef __cplusplus
  31. extern "C" {
  32. #endif
  33.  
  34. enum __rlimit_resource {
  35. RLIMIT_CPU,
  36. RLIMIT_FSIZE,
  37. RLIMIT_CORE,
  38. RLIMIT_DATA,
  39. RLIMIT_STACK,
  40. RLIMIT_RSS,
  41. RLIMIT_MEMLOCK,
  42. RLIMIT_NPROC,
  43. RLIMIT_NOFILE,
  44. RLIMIT_OFILE = RLIMIT_NOFILE,
  45. RLIMIT_NLIMITS
  46. };
  47.  
  48.  
  49. struct rlimit
  50.   {
  51.     /* The current (soft) limit.  */
  52.     int rlim_cur;
  53.     /* The hard limit.  */
  54.     int rlim_max;
  55.   };
  56.  
  57. /* Value used to indicate that there is no limit.  */
  58. #define RLIM_INFINITY 0x7fffffff
  59.  
  60. /* Put the soft and hard limits for RESOURCE in *RLIMITS.
  61.    Returns 0 if successful, -1 if not (and sets errno).  */
  62. extern int getrlimit (enum __rlimit_resource, struct rlimit *);
  63.  
  64. /* Set the soft and hard limits for RESOURCE to *RLIMITS.
  65.    Only the super-user can increase hard limits.
  66.    Return 0 if successful, -1 if not (and sets errno).  */
  67.  
  68. extern int setrlimit (enum __rlimit_resource, struct rlimit *);
  69.  
  70. /* Whose usage statistics do you want?  */
  71. enum __rusage_who
  72. /* The macro definitions are necessary because some programs want
  73.    to test for operating system features with #ifdef RUSAGE_SELF.
  74.    In ANSI C the reflexive definition is a no-op.  */
  75.   {
  76.     /* The calling process.  */
  77.     RUSAGE_SELF = 0,
  78. #define    RUSAGE_SELF    RUSAGE_SELF
  79.     /* All of its terminated child processes.  */
  80.     RUSAGE_CHILDREN = -1
  81. #define    RUSAGE_CHILDREN    RUSAGE_CHILDREN
  82.   };
  83.  
  84.  
  85. /* Structure which says how much of each resource has been used.  */
  86. struct rusage
  87.   {
  88.     /* Total amount of user time used.  */
  89.     struct timeval ru_utime;
  90.     /* Total amount of system time used.  */
  91.     struct timeval ru_stime;
  92.     /* Maximum resident set size (in kilobytes).  */
  93.     int ru_maxrss;
  94.     /* Amount of sharing of text segment memory
  95.        with other processes (kilobyte-seconds).  */
  96.     int ru_ixrss;
  97.     /* Amount of data segment memory used (kilobyte-seconds).  */
  98.     int ru_idrss;
  99.     /* Amount of stack memory used (kilobyte-seconds).  */
  100.     int ru_isrss;
  101.     /* Number of soft page faults (i.e. those serviced by reclaiming
  102.        a page from the list of pages awaiting reallocation.  */
  103.     int ru_minflt;
  104.     /* Number of hard page faults (i.e. those that required I/O).  */
  105.     int ru_majflt;
  106.     /* Number of times a process was swapped out of physical memory.  */
  107.     int ru_nswap;
  108.     /* Number of input operations via the file system.  Note: This
  109.        and `ru_oublock' do not include operations with the cache.  */
  110.     int ru_inblock;
  111.     /* Number of output operations via the file system.  */
  112.     int ru_oublock;
  113.     /* Number of IPC messages sent.  */
  114.     int ru_msgsnd;
  115.     /* Number of IPC messages received.  */
  116.     int ru_msgrcv;
  117.     /* Number of signals delivered.  */
  118.     int ru_nsignals;
  119.     /* Number of voluntary context switches, i.e. because the process
  120.        gave up the process before it had to (usually to wait for some
  121.        resource to be available).  */
  122.     int ru_nvcsw;
  123.     /* Number of involuntary context switches, i.e. a higher priority process
  124.        became runnable or the current process used up its time slice.  */
  125.     int ru_nivcsw;
  126.   };
  127.  
  128. /* Return resource usage information on a process.  */
  129. extern int getrusage (enum __rusage_who, struct rusage *);
  130.  
  131. /* Function depends on first parameter.
  132.    1 = Return the limit on the size of a file, in units of 512 bytes.
  133.    2 = Set the limit on the size of a file to new limit.  Only the
  134.        super-user can increase the limit.
  135.    3 = Return the maximum possible address of the data segment.
  136.    4 = Return the maximum number of files that the calling process can open.  */
  137. extern long int ulimit (int, int);
  138.  
  139.  
  140. /* Priority limits.  */
  141. #define    PRIO_MIN    -20    /* Minimum priority a process can have.  */
  142. #define    PRIO_MAX    20    /* Maximum priority a process can have.  */
  143.  
  144. /* The type of the 'which' argument to `getpriority' and `setpriority',
  145.    indicating what flavor of entity the WHO argument specifies.  */
  146. enum __priority_which
  147.   {
  148.     PRIO_PROCESS = 0,        /* WHO is a process ID.  */
  149.     PRIO_PGRP = 1,        /* WHO is a process group ID.  */
  150.     PRIO_USER = 2        /* WHO is a user ID.  */
  151.   };
  152.  
  153. /* Return the highest priority of any process.  */
  154. extern int getpriority (enum __priority_which, int);
  155.  
  156. /* Set the priority of all processes.  */
  157. extern int setpriority (enum __priority_which, int, int);
  158.  
  159. /* Alter the priority of the current process by 'increment'.  */
  160. extern int nice (int increment);
  161.  
  162. #ifdef __cplusplus
  163.     }
  164. #endif
  165.  
  166. #endif /* resource.h  */
  167.